
//
//  UIButton+bottom.m
//  kuangjia
//
//  Created by 张帅 on 15/10/3.
//  Copyright © 2015年 ZhangShuai. All rights reserved.
//

#import "UIButton+bottom.h"

@implementation UIButton (bottom)


-(instancetype)initWithTitle:(NSString *)title image:(UIImage *)image color:(UIColor *)color fontSize:(CGFloat)fontSize{
    
    UIButton *btn=[[ UIButton alloc] init];
    

    [btn setTitle:title forState:UIControlStateNormal];
        [btn setImage:image forState:UIControlStateNormal];
    [btn setTitleColor:color forState:UIControlStateNormal];
    
    btn.titleLabel.font = [UIFont systemFontOfSize:fontSize];
    
    [btn sizeToFit];
    return btn;
}

-(instancetype)initWithTitle:(NSString *)title fontSize:(CGFloat)font{
    UIButton *btn =[[UIButton alloc] init];
    
    [btn setTitle:title forState:(UIControlStateNormal)];
    
    btn.titleLabel.font= [UIFont systemFontOfSize:font];
    
    [btn setTintColor:[UIColor whiteColor]];
    [btn setBackgroundColor:[UIColor darkGrayColor]];
    [btn sizeToFit];
    return btn;


}
-(instancetype)initWithImageName:(NSString *)imageName{

    UIButton *btn =[[UIButton alloc] init];
    [btn setImage:[UIImage imageNamed:imageName] forState:(UIControlStateNormal)];
    NSString *imgName =[NSString stringWithFormat:@"%@__highlighted",imageName];
   
    [btn setImage:[UIImage imageNamed:imgName] forState:(UIControlStateHighlighted)];
  
    [btn sizeToFit];
    return btn;
}


+ (instancetype)buttonWithImageName:(NSString*)imageName Target:(NSObject*)target selector:(SEL)selector
{
    
    UIButton* btn = [[UIButton alloc] init];
    if (imageName) {
        [btn setImage:[UIImage imageNamed:imageName] forState:(UIControlStateNormal)];
        [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted", imageName]] forState:(UIControlStateHighlighted)];
    }
    if (selector) {
        [btn addTarget:target action:selector forControlEvents:(UIControlEventTouchUpInside)];
    }
    [btn sizeToFit];
    return btn;
}

@end
